
package com.hy.erp.inventory.pojo ;

import javax.persistence.Column ;
import javax.persistence.Entity ;
import javax.persistence.FetchType ;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne ;
import javax.persistence.NamedQuery ;
import javax.persistence.OneToOne ;
import javax.persistence.PrimaryKeyJoinColumn ;
import javax.persistence.Table ;

import org.hibernate.annotations.Index ;
//import org.jboss.seam.annotations.Name ;

import com.hy.erp.inventory.dao.interfaces.ICityDao;
import com.hy.erp.inventory.pojo.interfaces.ICity;
import com.hy.erp.inventory.pojo.interfaces.IPosition;
import com.hy.mydesktop.shared.persistence.domain.gxt.MyBaseModel;
//import com.hy.erp.inventory.vsoft.libra.enterprise.framework.persistence.api.annotation.DaoA;
//import com.hy.erp.inventory.vsoft.libra.enterprise.framework.persistence.entity.AbstractPersistentEntity;
/**
 * 
 * <ul>
 * <li>开发作者：李冰</li>
 * <li>设计日期：2010-10-5；时间：下午04:18:53</li>
 * <li>类型名称：City</li>
 * <li>设计目的：市</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
//@Name("city")
@ Entity 
@Table(name="t_city")
//@ DaoA ( ICityDao.class )
//@ NamedQuery ( name = "findCityByProvinceId" , query = "select c from com.pojo.City c where c.province.identifier=?")
//public class City extends AbstractPersistentEntity implements ICity
public class City extends MyBaseModel //implements IPositonType
{
	private static final long	serialVersionUID	=
	                                                  - 6800281128983589922L ;


	/**
	 * 构造函数
	 */
	public City ( )
	{
		super ( ) ;
	}

	@ Column ( name = "abbreviation" , length = 50)
	@ Index ( name = "abbreviationIndex" )
	public String getAbbreviation ( )
	{
		 return this.get(ICity.ABBREVIATION) ; 
	}

	public void setAbbreviation (
									String abbreviation )
	{
		super.set (ICity.ABBREVIATION , abbreviation );
	}
	@ Column ( name = "ancillaryCode" , length = 50)
	@ Index ( name = "ancillaryCodeIndex" )
	public String getAncillaryCode ( )
	{
		 return this.get(ICity.ANCILLARYCODE) ;
	}

	public void setAncillaryCode (
									String ancillaryCode )
	{
		super.set (ICity.ANCILLARYCODE , ancillaryCode );
	}

	@ Column ( name = "description" , length = 50)
	@ Index ( name = "descriptionIndex" )
	public String getDescription ( )
	{
		 return this.get(ICity.DESCRIPTION) ;
	}

	public void setDescription (
									String description )
	{
		super.set (ICity.DESCRIPTION , description );
	}
	@ Column ( name = "name" , length = 50)
	@ Index ( name = "nameIndex" )
	public String getName ( )
	{
		 return this.get(ICity.NAME) ;
	}

	public void setName (
							String name )
	{
		super.set (ICity.NAME , name );
	}
	@ Column ( name = "namedCode" , length = 50)
	@ Index ( name = "namedCodeIndex" )
	public String getNamedCode ( )
	{
		 return this.get(ICity.NAMECODE) ;
	}

	public void setNamedCode (
								String namedCode )
	{
		super.set (ICity.NAMECODE , namedCode );
	}
	

	//@ManyToOne(targetEntity=LocationType.class,fetch=FetchType.LAZY)
	//@PrimaryKeyJoinColumn
	@ManyToOne()
	@JoinColumn(name="locationType_identifier")
	public LocationType getLocationType ( )
		{
		 return this.get(ICity.LOCATIONTYPE) ;
		}

	public void setLocationType (
										LocationType locationType )
	{	
			super.set (ICity.LOCATIONTYPE , locationType );
			if (locationType!=null) {
				
				super.set (ICity.LOCATIONTYPE_FOR_SHOW , locationType.getName() );
			}

	}
	public String getLocationTypeForShow ()
	{
			/*if (this.get(ICity.LOCATIONTYPE_FOR_SHOW)==null) {
				if (this.getLocationType().getName()!=null) {
					
					return this.getLocationType().getName();
				} else {
					return null;
				}
			} else {
				return this.get(ICity.LOCATIONTYPE_FOR_SHOW) ;

			}*/
		return this.get(ICity.LOCATIONTYPE_FOR_SHOW) ;

	}

	public void setLocationTypeForShow(String locationTypeForShow) {
			
			super.set(ICity.LOCATIONTYPE_FOR_SHOW, locationTypeForShow);

	}
		
	

//		@OneToOne(fetch=FetchType.LAZY ,targetEntity=Province.class)
		@ManyToOne
		@JoinColumn(name="province_identifier")
		public  Province  getProvince ( )
		{
			return this.get(ICity.PROVINCES) ;
		}

		public void setProvince (
									Province province )
		{
			super.set (ICity.PROVINCES , province );
		}
		
		
		
		public String getProvinceForShow ()
		{
				/*if (this.get(ICity.PROVINCES_FOR_SHOW)==null) {
					if (this.getProvince().getName()!=null) {
						
						return this.getProvince().getName();
					} else {
						return null;
					}
				} else {
					return this.get(ICity.PROVINCES_FOR_SHOW) ;

				}*/
			return this.get(ICity.PROVINCES_FOR_SHOW) ;

		}

		public void setProvinceForShow(String locationTypeForShow) {
				
				super.set(ICity.PROVINCES_FOR_SHOW, locationTypeForShow);

		}
			
}
